<template>
  <div class="about">
    <div>
      <van-nav-bar left-text="返回">
        <template #left>
          <van-icon @click="back" name="arrow-left" size="18" />
        </template>
        <template #title>{{ drug.drug_name }}</template>
      </van-nav-bar>
    </div>
    <!-- 轮播图 -->
    <div>
      <van-swipe :autoplay="3000">
        <van-swipe-item><img :src="drug.drug_cover"></van-swipe-item>
        <van-swipe-item><img :src="drug.drug_cover"></van-swipe-item>
        <van-swipe-item><img :src="drug.drug_cover"></van-swipe-item>
        <van-swipe-item><img :src="drug.drug_cover"></van-swipe-item>
        <template #indicator="{ active, total }">
          <div class="custom-indicator">{{ active + 1 }}/{{ total }}</div>
        </template>
      </van-swipe>
    </div>
    <!-- 标签 -->
    <div class="bq">
      <van-tabs type="card" shrink style="text-align: center;" color="#fff" background="rgb(247,247,247)"
        title-active-color="#000" title-inactive-color="rgba(0,0,0,0.7)">
        <van-tab title="商品详情"></van-tab>
        <!-- <van-tab title="用药提示"></van-tab> -->
        <!-- <van-tab title="问答"></van-tab> -->
      </van-tabs>
      <!-- 优惠 -->

      <div class="you-hui">
        <b style="float: left;font-size: 20px;color: white;margin: 18px 0 0 4px;">￥</b>
        <b class="da-da" style="; float: left;color: white;font-size: 29px;margin-top: 15px;">{{ drug.durg_price }}</b>
        <s style="float: left;font-size: 20px;color:rgba(247, 247, 247, 0.6);margin: 20px 0 0  0px;"><b>￥{{ (
          drug.durg_price * 1.25).toFixed(1) }}</b></s>
        <div class="yu-gu">
          <span><b style="float: left; margin: 5px 0 0 7px; color:rgb(222, 105, 91);">预估到手
              ￥{{ drug.durg_price }}</b><van-icon size="10px" color="chocolate" name="question-o" /></span>
        </div>
        <div style="margin-top: 5px;margin-right: -6px;">
          <b style="font-size: 17px; color: white;">折扣优惠</b>
          <br>
          <span style="font-size: 13px; color: rgba(255, 255, 255, 0.5);">8.08折 限1份</span>
        </div>
      </div>
      <!-- 优惠券列表 -->
      <br>
      <!-- 背景 -->
      <div style="width: 92%;height: 800px;background-color: white; z-index: 1;margin: auto;">
        <!-- 配送 -->
        <div style="display: flex; z-index: 2;">
          <div
            style="height: 25px;float: left;font-weight:bolder; font-size: 95%;padding:5px 0 0 0px; width: 250px;background-color:  rgb(251, 247, 246);color: rgb(219, 103, 75 );border-radius: 25px;margin: 5px;">
            配送费立减4元</div>
          <div
            style="height: 25px; float: right;font-weight:bolder;  font-size: 95%; padding-top: 5px;width: 100px;background-color:  rgb(251, 247, 246); color: rgb(219, 103, 75 ); border-radius: 25px;margin: 5px;margin-left: 155px;">
            领券<van-icon name="arrow" />
          </div>
        </div>
        <!-- 优惠券栏 -->
        <div style="display: flex;">
          <div
            style="border: 1px solid rgb(240, 223, 229) ; border-radius: 25px 10px 10px 25px; height: 36px; width: 69%;margin-left: 6%; background-color: rgba(240, 223, 229,0.2);">
            <b style="float: left;margin: 9px 0px 0px 11px;color: rgb(229, 51, 54);">￥</b><b class="yh-da">8</b><span
              style="float: left;margin: 8px 0 0 3px;font-size: 13px;color: rgb(208, 135, 155);">满39可用</span><b
              style="float: left;font-size: 14px; margin:-18px 0px 0px  59px ;color: rgb(229, 51, 54); ">购省钱包满39减8</b>
          </div>
          <div
            style="border: 1px solid rgb(240, 223, 229);border-radius: 10px 25px 25px 10px; height: 36px; width: 18%; background-color:  rgba(240, 223, 229,0.2);">
            <b style="float: left; margin: 9px 0 0 4px ;color: rgb(229, 51, 54);font-size: 13px;">去查看<van-icon
                name="arrow" /></b>
          </div>
        </div>
        <!-- 药品名 -->
        <div>
          <div style="display: flex;height: 55px; width: 100%;"><span
              style="float: left; font-weight:bolder;font-size: 22px; margin-top: 10px;">{{ drug.drug_name }}</span>
          </div>
          <div style="display: flex; margin-top: 10px; margin-left: 3px;padding-bottom: 25px;">
            <span
              style="background-color:rgb(241, 249, 249);color: rgb(143, 211, 196);height: 21px; width: 55px;border-radius: 25px;">处方药</span>
            <span
              style="margin-top: 1px; margin-left: 10px;color: rgba(0, 0, 0, 0.3);font-size: 14px;">处方药需凭处方在药师指导下购买和使用</span>
          </div>
        </div>
        <!-- 药品功能 -->
        <div
          style="border-radius: 20px; display: flex; height: 80px; width: 92%;margin: auto;background-color: rgb(250, 251, 253);">
          <div style="margin: 10px 0 0 10px; font-weight: bolder;font-size: 20px;width: 40px;">用药提示</div>
          <div class="su-xian">
            <div class="van-multi-ellipsis--l2"
              style="height: 45px; margin-left: 10px; font-size: 13px;color: rgba(0, 0, 0, 0.5);">
              <b style="font-weight: bolder;color: black;font-size: 18px;">功能主治:</b>
              {{ drug.drug_effect }}
            </div>
          </div>
          <div class="su-xian2">
            <div class="van-multi-ellipsis--l2"
              style="height: 45px; margin-left: 10px; font-size: 13px;color: rgba(0, 0, 0, 0.5);">
              <b style="font-weight: bolder;color: black;font-size: 18px;">用法用量:</b>
              {{ drug.drug_use }}
            </div>
          </div>
        </div>
        <!-- .................. -->
        <!-- 优惠券单元格 -->
        <van-collapse v-model="activeName" accordion>
          <van-collapse-item size="large" title="药品通用名称" name="1">
            {{ drug.drug_name }}。
          </van-collapse-item>
          <van-collapse-item size="large" title="用药不良反应" name="2">
            {{ drug.drug_bad }}
          </van-collapse-item>
          <van-collapse-item size="large" title="有效期" name="3">
            {{ drug.drug_term }}
          </van-collapse-item>
          <van-collapse-item size="large" title="功能主治" name="4">
            {{ drug.drug_effect }}
          </van-collapse-item>
          <van-collapse-item size="large" title="用量用法" name="5">
            {{ drug.drug_use }}
          </van-collapse-item>
        </van-collapse>
      </div>
    </div>

    <!-- 购买功能栏 -->
    <div style=" display: flex;">
      <van-action-bar>
        <!-- <van-action-bar-icon @click.native="router.push(`/card`)" icon="cart-o" text="购物车" /> -->
        <van-action-bar-button color="rgb(48,50,52)" type="warning">
          <van-cell style="height: 40.5px; background-color:rgb(48,50,52) ;" @click="showPopup"><text
              style="font-size:18px; color: rgb(244, 233, 204);">
              加入购物车
            </text></van-cell>
        </van-action-bar-button>
        <van-popup v-model:show="show" closeable close-icon="close" position="bottom" :style="{ height: '30%' }">
          <van-card :title="drug.drug_name" :price="drug.durg_price" :desc="drug.drug_effect" :thumb="drug.drug_cover" />
          <div style="background-color: rgb(247, 248, 250);">
            <div style="float: right;">
              <van-stepper input-width="48" button-size="42" v-model="value" min="1" max="99" integer />
            </div>
            <div style=" float: left;">
              <span style="font-size: 30px;color: rgb(229, 51, 54);">￥{{ (drug.durg_price * value).toFixed(1) }}</span>
            </div>
            <van-button @click.native="router.push(`/card`)" style=" width: 100%;" round type="warning">加入购物车</van-button>
          </div>
        </van-popup>
        <van-action-bar-button @click.native="router.push(`/shopping`)" color="rgb(245, 204, 99)" type="danger">
          <text style="font-size:16px;  color: rgb(34, 36, 30); flex-direction: column;">立即购买<br><span
              style="font-size: 8px;">差￥11.8起送</span></text>
        </van-action-bar-button>

      </van-action-bar>
    </div>
    <!-- @click.native="router.push(`/shopping`)" -->
  </div>
</template>

<script lang="ts" setup>
import Drug from '@/type/Drug';
import { useRoute, useRouter, } from 'vue-router';
import { onMounted, ref } from 'vue';
import httpApi from '@/http'
import { showNotify } from 'vant';
// import { showPopup } from 'vant';

const value = ref(1);
const drug = ref<Drug[]>([])
// 返回上一页
const activeName = ref('1');
// const router = router()
const back = () => history.back()
const route = useRoute()
const router = useRouter()
const drug_id = route.params.id
// console.log(route);
// const show1 = ref(false);
const show = ref(false);
const showPopup = () => {
  show.value = true;
};
onMounted(() => {
  httpApi.medicineApi.queryDrugById({ drug_id }).then(res => {
    // console.log('spxqxx', res);
    drug.value = res.data.data[0]

  })
})
</script>
<style scoped>
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  width: 96%;
  height: 160px;
  background-color: #fff;
  border-radius: 25px;
}

.su-xian {
  /* display: flex; */
  width: 35%;
  height: 75%;
  margin-top: 10px;
  margin-left: 20px;
  /* background-color: red; */
  border-left: 1px solid rgba(0, 0, 0, 0.1);
}

.su-xian2 {
  /* display: flex; */
  width: 35%;
  height: 75%;
  margin-top: 10px;
  margin-left: 20px;
  /* background-color: red; */
  border-left: 1px solid rgba(0, 0, 0, 0.1);
}

/* :root:root {
  --van-nav-bar-background: rgb(237, 108, 53);
} */
:root {
  --van-popup-background: rgb(244, 233, 204);
}

.custom-indicator {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 2px 5px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.1);
}

img {
  height: 250px;
  width: 100%;
}

.bq {
  display: inline-block;
  height: 100%;
  width: 97%;
  background-color: rgb(247, 247, 247);
  border-radius: 25px 25px;
  z-index: -1
}

.you-hui {

  display: inline-block;
  text-align: center;
  background-color: rgb(237, 108, 53);
  width: 100%;
  height: 55px;
  float: none;
  border-radius: 15px 15px 0 0;
}


.yu-gu {
  border-radius: 25px;
  height: 30px;
  width: 130px;
  background-color: rgb(243, 243, 243);
  float: left;
  margin-top: 10px;
  margin-left: 13px;
}

.yh-da {
  font-size: 200%;
  float: left;
  color: rgb(229, 51, 54);
}
</style>